Use
PauseThread(3);
to "Kill" a thread. But if possible it always better to have a thread clean up and terminate itself.
TK
from KMotionDef.h
// M U L T I - T H R E A D S U P P O R T
// user threads are numbered 1 .. n
void StartThread(int thread); // starts a downloaded program at it's entry point
void PauseThread(int thread); // stops a thread from executing
int ResumeThread(int thread); // resumes a thread after a pause
void ThreadDone(void); // call to terminate current thread
Group: DynoMotion |
Message: 974 |
From: Allen |
Date: 3/14/2011 |
Subject: Re: Kill thread via NotifyPlugin |
My problem is that when I press reset in Mach while the machine is homing the thread continues to run in the background. I used the PauseThread command (which does stop the thread from running) as well as the updated plugin that stops jogging if the reset is pressed. If I open the Axis window in KMotion axis #4 (my slaved axis) is still moving even though the thread has been killed and mach is in reset mode.
I understand the best way is to not handle estop via software, etc. and that is fine and ultimately I will be killing the drives with an external relay but that doesnt help me to completely kill all aspects of the homing routine running in the background.
Thanks for your help,
Allen
Allen
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Use
> Â
> PauseThread(3);
> Â
> to "Kill" a thread. But if possible it always better to have a thread clean up
> and terminate itself.Â
> Â
> TK
> Â
> from KMotionDef.h
> Â
> // M U L T I - T H R E A D S U P P O R T
> // user threads are numbered 1 .. nvoidStartThread(intthread); // starts a
> downloaded program at it's entry pointvoidPauseThread(intthread); // stops a
> thread from executingintResumeThread(intthread); // resumes a thread after a
> pause voidThreadDone(void); // call to terminate current thread
>
>
>
>
> ________________________________
> From: Allen <agray@...>
> To: DynoMotion@yahoogroups.com
> Sent: Mon, March 14, 2011 11:19:03 AM
> Subject: [DynoMotion] Kill thread via NotifyPlugin
>
> Â
> Can I call a script command like this in a user program:
>
> Kill(3);
>
> I need to kill that thread if RESET is active in mach3. I placed this command in
> my notify user program and get an error "undefined symbol "Kill" "
>
|
|
Group: DynoMotion |
Message: 975 |
From: Tom Kerekes |
Date: 3/14/2011 |
Subject: Re: Kill thread via NotifyPlugin |
Hi Allen,
Yes once a motion is initiated, the motion will continue regardless of the state of the thread.
I think the best solution is to add code in the Home routine to watch for Mach3 Reset. The home routine can monitor the Amplifier Enable I/O bits and if it sees one disabled then it should stop all motions and terminate itself. If you aren't using Amplifier Enables we could add a Virtual Bit (Bit48) that we could use as a flag to the Home routine.
I believe we worked on a similar issue before and added code to watch for external EStop and to stop all motion with the following code:
// check for estop
if (ReadBit(133))
{
Jog(0,0.0); // StopMotion
Jog(4,0.0); // StopMotion
Jog(1,0.0); // StopMotion
Jog(3,0.0); // StopMotion
printf( "Homing Aborted!\n");
return;
}
We can change that to stop and terminate on external estop OR Mach3 Reset by doing
// check for estop or Amplifier Disabled
if (ReadBit(133) || ReadBit(48))
{
Jog(0,0.0); // StopMotion
Jog(4,0.0); // StopMotion
Jog(1,0.0); // StopMotion
Jog(3,0.0); // StopMotion
printf( "Homing Aborted!\n");
return;
}
As a side note, hitting RESET in the new plugin will cause all axes in the coordinate system (X,Y,Z) and stopping the master axis would normally also indirectly stop any slaved axes. But until homing (and squaring) is complete the axes are not yet slaved together which is why the second X axis never stops. But regardless, changing the home routine to watch for RESET and stop should solve the issue.
Thanks
TK
Group: DynoMotion |
Message: 976 |
From: Allen |
Date: 3/15/2011 |
Subject: Re: Kill thread via NotifyPlugin |
How exactly do I tie the virtual bit to mach3's reset? I enabled one of the "Enable" signals in Ports&Pins and set it up for Port1 Pin48. As I toggle the RESET button in mach I use the console in KMotion to ReadBit48 but the state does not change.
Allen
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Allen,
>
> Yes once a motion is initiated, the motion will continue regardless of the state
> of the thread.
>
> I think the best solution is to add code in the Home routine to watch for Mach3
> Reset. The home routine can monitor the Amplifier Enable I/O bits and if it
> sees one disabled then it should stop all motions and terminate itself. If you
> aren't using Amplifier Enables we could add a Virtual Bit (Bit48) that we could
> use as a flag to the Home routine.
>
> I believe we worked on a similar issue before and added code to watch for
> external EStop and to stop all motion with the following code:
>
> // check for estop{
>    Jog(0,0.0); if(ReadBit(133))// StopMotion   Jog(4,0.0); // StopMotion  Â
> Jog(1,0.0); // StopMotion   Jog(3,0.0); // StopMotion   printf(
> }"Homing Aborted!\n");Â Â Â return;
>
> We can change that to stop and terminate on external estop OR Mach3 Reset by
> doing
>
>
> // check for estop or Amplifier Disabled{
>    Jog(0,0.0); if(ReadBit(133) || ReadBit(48))// StopMotion   Jog(4,0.0); //
> StopMotion   Jog(1,0.0); // StopMotion   Jog(3,0.0); // StopMotion   printf(
> }
> Â "Homing Aborted!\n");Â Â Â return;As a side note, hitting RESET in the new plugin
> will cause all axes in the coordinate system (X,Y,Z) and stopping the master
> axis would normally also indirectly stop any slaved axes.  But until homing (and
> squaring) is complete the axes are not yet slaved together which is why the
> second X axis never stops. But regardless, changing the home routine to watch
> for RESETÂ and stop should solve the issue.
>
> Thanks
> TK
>
>
> Â
>
>
>
> ________________________________
> From: Allen <agray@...>
> To: DynoMotion@yahoogroups.com
> Sent: Mon, March 14, 2011 12:10:12 PM
> Subject: [DynoMotion] Re: Kill thread via NotifyPlugin
>
> Â
> My problem is that when I press reset in Mach while the machine is homing the
> thread continues to run in the background. I used the PauseThread command (which
> does stop the thread from running) as well as the updated plugin that stops
> jogging if the reset is pressed. If I open the Axis window in KMotion axis #4
> (my slaved axis) is still moving even though the thread has been killed and mach
> is in reset mode.
>
> I understand the best way is to not handle estop via software, etc. and that is
> fine and ultimately I will be killing the drives with an external relay but that
> doesnt help me to completely kill all aspects of the homing routine running in
> the background.
>
> Thanks for your help,
> Allen
>
> Allen
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Use
> > ÃÂ
> > PauseThread(3);
> > ÃÂ
> > to "Kill" a thread.ÃÂ But if possible it alwaysÃÂ better to have a thread clean
> >up
> >
> > and terminate itself.ÃÂ
> > ÃÂ
> > TK
> > ÃÂ
> > from KMotionDef.h
> > ÃÂ
> > // M U L T I - T H R E A D S U P P O R T
> > // user threads are numbered 1 .. nvoidStartThread(intthread); // starts a
> > downloaded program at it's entry pointvoidPauseThread(intthread); // stops a
> > thread from executingintResumeThread(intthread); // resumes a thread after a
> > pause voidThreadDone(void); // call to terminate current thread
> >
> >
> >
> >
> > ________________________________
> > From: Allen <agray@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Mon, March 14, 2011 11:19:03 AM
> > Subject: [DynoMotion] Kill thread via NotifyPlugin
> >
> > ÃÂ
> > Can I call a script command like this in a user program:
> >
> > Kill(3);
> >
> > I need to kill that thread if RESET is active in mach3. I placed this command
> >in
> >
> > my notify user program and get an error "undefined symbol "Kill" "
> >
>
|
|
Group: DynoMotion |
Message: 977 |
From: Tom Kerekes |
Date: 3/15/2011 |
Subject: Re: Kill thread via NotifyPlugin |
Hi Allen,
I just tried it and it works for me. I used Config | Ports&Pins | Output Signals | Enable1 | Enabled Pin 48 Port 1 ActiveLow=no
You might try it with bit 47 which is a KFLOP LED.
Do you have something else outputting to Bit 48?
TK
Group: DynoMotion |
Message: 978 |
From: Allen |
Date: 3/15/2011 |
Subject: Re: Kill thread via NotifyPlugin |
OK, that worked. Just had to change it to !ReadBit(47) though. I did have something on 48 but I also tested with 40 and still didn't work. Does now though, thanks :)
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Allen,
>
> I just tried it and it works for me. I used Config | Ports&Pins | Output
> Signals | Enable1 | Enabled Pin 48 Port 1 ActiveLow=no
>
> You might try it with bit 47 which is a KFLOP LED.
>
> Do you have something else outputting to Bit 48?
>
> TK
>
>
>
>
> ________________________________
> From: Allen agray@...|
> To: DynoMotion@yahoogroups.com
> Sent: Tue, March 15, 2011 7:04:31 AM
> Subject: [DynoMotion] Re: Kill thread via NotifyPlugin
>
> Â
> How exactly do I tie the virtual bit to mach3's reset? I enabled one of the
> "Enable" signals in Ports&Pins and set it up for Port1 Pin48. As I toggle the
> RESET button in mach I use the console in KMotion to ReadBit48 but the state
> does not change.
>
> Allen
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Allen,
> >
> > Yes once a motion is initiated, the motion will continue regardless of the
> >state
> >
> > of the thread.
> >
> > I think the best solution is to add code in the Home routine to watch for Mach3
> >
> > Reset.ÃÂ The home routine canÃÂ monitor the AmplifierÃÂ Enable I/O bits and if it
> >
> > sees one disabled then it should stop all motions and terminate itself.ÃÂ If
> >you
> >
> > aren't using Amplifier Enables we could add a Virtual Bit (Bit48) that we could
> >
> > use as a flag to the Home routine.
> >
> > I believe we worked on a similar issue before and added code to watch for
> > external EStop and to stop all motion with the following code:
> >
> > // check for estop{
> > ÃÂ ÃÂ ÃÂ Jog(0,0.0); if(ReadBit(133))// StopMotionÃÂ ÃÂ ÃÂ Jog(4,0.0); //
> >StopMotionÃÂ ÃÂ ÃÂ
> >
> > Jog(1,0.0); // StopMotionÃÂ ÃÂ ÃÂ Jog(3,0.0); // StopMotionÃÂ ÃÂ ÃÂ printf(
> > }"Homing Aborted!\n");ÃÂ ÃÂ ÃÂ return;
> >
> > We can change that to stop and terminate on external estop OR Mach3 Reset by
> > doing
> >
> >
> > // check for estop or Amplifier Disabled{
> > ÃÂ ÃÂ ÃÂ Jog(0,0.0); if(ReadBit(133) || ReadBit(48))// StopMotionÃÂ ÃÂ ÃÂ
> >Jog(4,0.0); //
> >
> > StopMotionÃÂ ÃÂ ÃÂ Jog(1,0.0); // StopMotionÃÂ ÃÂ ÃÂ Jog(3,0.0); //
> >StopMotionÃÂ ÃÂ ÃÂ printf(
> > }
> > ÃÂ "Homing Aborted!\n");ÃÂ ÃÂ ÃÂ return;As a side note, hitting RESET in the new
> >plugin
> >
> > will cause all axes in the coordinate system (X,Y,Z) and stopping the master
> > axis would normally also indirectly stop any slaved axes.ÃÂ ÃÂ But until homing
> >(and
> >
> > squaring) is complete the axes are not yet slaved together which is why the
> > second X axis never stops.ÃÂ But regardless, changing the home routine to watch
> >
> > for RESETÃÂ and stop should solve the issue.
> >
> > Thanks
> > TK
> >
> >
> > ÃÂ
> >
> >
> >
> > ________________________________
> > From: Allen <agray@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Mon, March 14, 2011 12:10:12 PM
> > Subject: [DynoMotion] Re: Kill thread via NotifyPlugin
> >
> > ÃÂ
> > My problem is that when I press reset in Mach while the machine is homing the
> > thread continues to run in the background. I used the PauseThread command
> >(which
> >
> > does stop the thread from running) as well as the updated plugin that stops
> > jogging if the reset is pressed. If I open the Axis window in KMotion axis #4
> > (my slaved axis) is still moving even though the thread has been killed and
> >mach
> >
> > is in reset mode.
> >
> > I understand the best way is to not handle estop via software, etc. and that is
> >
> > fine and ultimately I will be killing the drives with an external relay but
> >that
> >
> > doesnt help me to completely kill all aspects of the homing routine running in
>
> > the background.
> >
> > Thanks for your help,
> > Allen
> >
> > Allen
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Use
> > > ÃâÃÂ
> > > PauseThread(3);
> > > ÃâÃÂ
> > > to "Kill" a thread.ÃâàBut if possible it alwaysÃâàbetter to have a thread
> >clean
> >
> > >up
> > >
> > > and terminate itself.ÃâÃÂ
> > > ÃâÃÂ
> > > TK
> > > ÃâÃÂ
> > > from KMotionDef.h
> > > ÃâÃÂ
> > > // M U L T I - T H R E A D S U P P O R T
> > > // user threads are numbered 1 .. nvoidStartThread(intthread); // starts a
> > > downloaded program at it's entry pointvoidPauseThread(intthread); // stops a
>
> > > thread from executingintResumeThread(intthread); // resumes a thread after a
>
> > > pause voidThreadDone(void); // call to terminate current thread
> > >
> > >
> > >
> > >
> > > ________________________________
> > > From: Allen <agray@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Mon, March 14, 2011 11:19:03 AM
> > > Subject: [DynoMotion] Kill thread via NotifyPlugin
> > >
> > > ÃâÃÂ
> > > Can I call a script command like this in a user program:
> > >
> > > Kill(3);
> > >
> > > I need to kill that thread if RESET is active in mach3. I placed this command
> >
> > >in
> > >
> > > my notify user program and get an error "undefined symbol "Kill" "
> > >
> >
>
|
|
| | | | | |